<?php
declare(strict_types= 1);

use app\admin\model\ArcModel;
use function PHPUnit\Framework\assertTrue;
use app\admin\model\User;
use app\admin\service\CategoryServiceImpl;
use app\admin\service\UserServiceImpl;
use think\App;
use think\facade\Db;

class UserTest extends PHPUnit\Framework\TestCase{
    public static function setUpBeforeClass(): void
    {
        $http = (new App())->http;

        $response = $http->run();
    }

    function tearDown(): void
    {
        assertTrue(true);
    }

    public function testDb()
    {
        Db::startTrans();
        try {
            $userservice = new UserServiceImpl();
            $userservice->register("qqqqq111","wwwwww");
            $userservice->register("qqqqq122","wwwwww");
            $userservice->register("qqqqq133","wwwwww");
            // $userservice->delete(6);
            // $userservice->delete(7);
            // $userservice->delete(8);
            // $userservice->delete(9);
            // 提交事务
            Db::commit();
        } catch (\Exception $e) {
            // 回滚事务
            print("error");
            Db::rollback();
        }
    }
    public function test_demo() {
        // print("aaaaaaaaa");
        // $this->assertTrue(true);
     $userservice = new UserServiceImpl();
     $userservice->register("qqqqq","wwwwww");
    }
    public function test_demo2() {
       $catservice = new CategoryServiceImpl();
    //    $catservice->add("aaa",0);
       $catservice->add("ccccc",1);
        // $this->assertTrue(true);
    }

    public function testModel()
    {
        $model = new ArcModel();
        $model->name = "aaa";
        $model->save();
    }
    
}
